package Lint;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSessionEvent;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class LogoutServlet extends HttpServlet {
    private ServletContext context = null;
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {

        context = request.getSession().getServletContext();
        if (context.getAttribute("loginUsers")!=null){
            context.setAttribute("loginUsers",(Integer)context.getAttribute("loginUsers")-1);

        }
        else {
            context.setAttribute("loginUsers", 0);
        }
        request.getRequestDispatcher("/logout.jsp").forward(request,response);
    }
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html;charset=utf-8");

    }
}
